<template>
  <div id="app">
    <h1>{{counter}}</h1>
    <button @click="colc(1)">+</button>
    <button @click="colc(-1)">-</button>
    <button @click="asyncAdd(1)">异步++</button>
    <h1>{{counter|counterFilter}}</h1>
  </div>
</template>

<script>
export default {
  name: 'App',
  filters: {
    counterFilter ( value ) {
      let result = value % 2 === 0 ? "偶数" : "奇数"
      return result 
    }
  },
  data () {
    return {
      counter: 520
    }
  },
  methods: {
    colc (num) {
      this.counter += num
    },
    asyncAdd (num) {
      setTimeout( () => {
        this.counter += num
      }, 2000 )
    }
  }
  
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

#nav {
  padding: 30px;
}

#nav a {
  font-weight: bold;
  color: #2c3e50;
}

#nav a.router-link-exact-active {
  color: #42b983;
}
</style>
